﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Data.OleDb;

namespace Aandelendelen.Db
{
	internal class CachedResult
	{
		internal StringCollection DependentTables;
		internal object QueryResult;
		internal string Key;

		internal static string CreateCacheKey(string queryName, StringCollection dependentTables, OleDbCommand command)
		{
			if (dependentTables.Count == 0)
				return null;

			StringBuilder cache = new StringBuilder(128);
			cache.Append(queryName);
			cache.Append("_");
			foreach (OleDbParameter par in command.Parameters)
			{
				cache.Append(par.ParameterName);
				cache.Append("=");
				cache.Append(par.Value.ToString());
			}

			return cache.ToString();
		}
	}
}
